package com.server.modules.api.service.impl;

import com.server.common.utils.PathUtils;
import com.server.modules.api.service.IJPushService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lulian on 2016/8/31.
 */
@Service
public class JPushServiceImpl extends BaseJPushService implements IJPushService {
    public JPushServiceImpl() {
        super( PathUtils.getPropertiesKeyValue("application.properties","JPush_Secret"),
                PathUtils.getPropertiesKeyValue("application.properties","JPush_key"),
                PathUtils.getPropertiesKeyValue("application.properties","JPush_open"));
    }

    public void pushEventMsg(String content,String alias,String eventId) {
        Map<String, String> extras = new HashMap<String, String>();
        extras.put("e", eventId);//打开事件
        pushNotification2One(content, alias, extras);
    }

    public void pushNoticeMsg(String content,String alias,String noticeId) {
        Map<String, String> extras = new HashMap<String, String>();
        extras.put("n", noticeId);//无参数打开APP，有参数打开URL
        pushNotification2One(content, alias, extras);
    }

    public void pushUrlMsg(String content,String alias,String url){
        Map<String, String> extras = new HashMap<String,String>();
        extras.put("u", url);//无参数打开APP，有参数打开URL
        pushNotification2One(content, alias, extras);
    }

    public void pushMsg(String content,String alias){
        Map<String, String> extras = new HashMap<String, String>();
        pushNotification2One(content, alias, extras);
    }

    public static void main(String[] args) {
        JPushServiceImpl pushService = new JPushServiceImpl();
        pushService.pushEventMsg("test","140f97d9967040039f09dd8f2444a9a0","6793fb142e3b4e4d8da969d7ccd472bf");
    }
}
